package com.tbit.uqbike.webmanager.controller;

import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.object.pojo.OutAge;
import com.tbit.common.entity.pojo.dto.OutAgeDTO;
import com.tbit.uqbike.service.business.OutAgeService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Objects;

/**
 * 一键停运配置控制层
 * @author <a href="mailto:liu.haoxiang@tbit.com.cn">BUGXiang</a>
 * @version 1.0
 * @since 2025-1-22
 */
@RestController
@RequestMapping("/outAge")
public class OutAgeController {


    @Resource
    private OutAgeService outAgeService;


    /**
     * 查询一键停运配置
     * @param dto 入参
     * @return OutAge
     */
    @GetMapping("/queryOutAge")
    public Result<OutAge> queryOutAge(OutAgeDTO dto){
        if (Objects.isNull(dto.getBrandId()) && Objects.isNull(dto.getAccountId())){
            return Result.error("请选择品牌或区域");
        }
        return outAgeService.queryOutAge(dto);
    }


    /**
     * 编辑一键停运配置
     * @param outAge 一键停运配置
     * @return Result
     */
    @PostMapping("/addOrUpdate")
    public Result<Object> addOrUpdate(@RequestBody OutAge outAge){
        return outAgeService.addOrUpdate(outAge);
    }

}
